package com.zhangdi.dwdata.listener;

import com.zhangdi.dwdata.entity.BaseEntity;

import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import java.util.Date;

public class EntityListener {
    public EntityListener() {
    }

    @PrePersist
    public void prePersist(BaseEntity entity) {
        entity.setAddDate(new Date());
    }

    @PreUpdate
    public void preUpdate(BaseEntity entity) {
        entity.setLastDate(new Date());
    }
}
